<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<a onclick="AddString(456ssfd)">决定性的十年里</a>
<script src="js/jquery-3.2.1.min.js"></script>
<script>
	function AddString(key) {
		console.log("拼接a标签"+key);
	}
</script>

<script>
	table.on('tool(GatewayWidgetTable)', function (obj) {
		var layEvent = obj.event,
			UUID = obj.data.UUID;
		if (layEvent === 'WigInGateEditBar') {
			//todo:此处需用用接口替换
			var FlatTrData = '';
			for (var i = 0; i < data.Data.length; i++) {
				if (UUID == data.Data[i].UUID) {
					FlatTrData = data.Data[i];
				}
			}
			GatewayTpl($("#WightEditTpl").html()).render(FlatTrData, function (html) {
				var FlatsEditLayer = layer.open({
					type: 1,
					title: "编辑控件",
					content: html,
					area: ['40%', '30%'],
					btn:["确认","取消"],
					yes: function (index, layero) {
						form.on('submit(WidgetInGatVButton)', function (data) {
							$.ajax({
								url: "<{SPURL c = 'Access' a = 'WidgetUpdate' SPSubmit=''}>",
								data: {
									Form: {CnName:data.field.CnName,UUID:data.field.UUID}
								},
								type: "POST",
								success: function (data) {
									data = JSON.parse(data);
									if (data.Status == "1") {
										layer.msg("编辑成功");
										window.location.reload();
									} else {
										layer.msg(data.Data);
									}
								}
							});
						});
						$('div[lay-filter="WidgetInGatEditForm"]').find('button[lay-submit]').click();
					}
				});
			});
		}else if(layEvent === 'WigInGatForbidBar'){
			var NewStatus, that = this;
			if (obj.data.Status == 0) {
				NewStatus = 1;
			} else if (obj.data.Status == 1) {
				NewStatus = 0;
			}
			$.ajax({
				url: "<{SPURL c = 'Access' a = 'WidgetUpdate' SPSubmit=''}>",
				data: {
					Form: {UUID: UUID, Status: NewStatus}
				},
				success: function (data) {
					data = JSON.parse(data);
					if (data.Status == "1") {
						obj.update({
							Status: NewStatus
						});
						if (NewStatus == 0) {
							$(that).html("激活");
							$(that).removeClass("layui-btn-danger");
							layer.msg("禁用成功");
						} else if (NewStatus == 1) {
							$(that).html("禁用");
							$(that).addClass("layui-btn-danger");
							layer.msg("激活成功");
						}
					}else{
						layer.msg(data.Data);
					}
				}
			});
		}
	});
</script>

</body>
</html>

